// To simplify the use of the code component, the code is encapsulated in this worker. Users only need to subscribe to events in the event center to receive the scanned content.
import log from './dxLogger.js'
import dxMap from './dxMap.js'
import code from './dxCode.js'
import std from './dxStd.js'

const map = dxMap.get("default")
let options = map.get("__code__run_init")
let capturerOptions = options.capturer
let decoderOptions = options.decoder
function run() {
    code.worker.beforeLoop(capturerOptions, decoderOptions)
    log.info('code start......')
    std.setInterval(() => {
        try {
            code.worker.loop(options.mode, options.interval)
        } catch (error) {
            log.error(error)
        }
    }, 10)
}
try {
    run()
} catch (error) {
    log.error(error)
}